package com.alavente.adapters;

import java.util.Date;

import com.alavente.forms.DemandeAchatForm;
import com.alavente.objects.Categorie;
import com.alavente.objects.Client;
import com.alavente.objects.DemandeAchat;
import com.alavente.objects.SsCategorie;

public class DemandeAchatAdapter extends AbstractAdapter<DemandeAchatForm, DemandeAchat> {
	
	public DemandeAchat adapt(DemandeAchatForm form) {
		
		DemandeAchat businessObj = new DemandeAchat();		
		super.adapt(form, businessObj);
		
		businessObj.setCategorie(new Categorie(form.getNumCategorie()));
		businessObj.setSsCategorie(new SsCategorie(form.getNumSsCategorie()));
		businessObj.setClient(new Client(form.getNumUser()));
		
		Date date = new Date();
		businessObj.setDateDepot(date);
		businessObj.setDateFin(date);
		
		return businessObj;
	}
}
